{% extends '::backend.html.twig' %}
{% block contenido %}
{% block documentReadyJavascript %} 
    {{ parent() }}
    <script type="text/javascript" >
        $(".delete").on('click', function(e){
                e.preventDefault()
                $this = $(this);
                $("#confirmation-dialog").dialog({
                resizable: false,
                height:180,
                width:'auto',
                modal: true,
                title:"Alerta!",
                buttons: {
                    "Eliminar": function() {
                        $this.parent().submit();
                    },
                    Cancelar: function() {
                        $( this ).dialog( "close" );
                    }
                }
            });
        });
    </script>
{% endblock documentReadyJavascript %}
{% include 'BackendBundle:Default:flashAlerts.html.twig'%}
<legend>Listado de Usuarios</legend>
<table class="table table-striped table-bordered table-striped table-hover">
    <thead>
        <tr>
            <th>Usuario</th>
            <th>Apellido</th>
            <th>Nombre</th>
            <th>Email</th>
            <th>Acciones</th>
        </tr>
    </thead>
    <tbody>
    {% for entity in entities %}
        <tr>
            <td>{{ entity.username }}</td>
            <td>{{ entity.apellido }}</td>
            <td>{{ entity.nombre }}</td>               
            <td>{{ entity.email }}</td>
            <td valign="middle" align="center">
                <a class="btn btn-info  btn-small" href="{{ path('user_show', { 'id': entity.id }) }}">
                    <i class=" icon-plus"> </i> info</i>
                </a>
                {% set esEditor = (is_granted("ROLE_ADMIN") or is_granted("ROLE_SUPER_ADMIN")) %}
                {% include 'BackendBundle:Default:accionesConPermisos.html.twig' with {'basePath':'user','esEditor':(esEditor)}%}
            </td>
        </tr>
    {% endfor %}
    </tbody>
</table>
{% include 'BackendBundle:Default:paginador.html.twig' with { 'ruta': 'user' } only %}
<div class="form-actions">
     <a class="btn  btn-success" href="{{ path('user_new') }}">
        <i class="icon-plus" ></i> Agregar Usuario
    </a>
</div>
<div id="confirmation-dialog" style="display:none">
    <div class="alert alert-error">
        <strong>Borrará!</strong>  el usuario por completo, est&aacute; seguro?
    </div>
</div>
{% endblock %}